#ifndef __CW32_HAL_SPI_H_
#define __CW32_HAL_SPI_H_


#include "cw32_hal_def.h"
#include "cw32_hal_gpio.h"


#define SPI_MASTER_MODE	0
#define SPI_SLAVE_MODE	1
#define _IS_SPI_MODE(mode) ((mode == SPI_MASTER_MODE) || (mode == SPI_SLAVE_MODE))

#define IDLE_MODE_0 0	//CPOL = 0 & CPHA = 0
#define IDLE_MODE_1 1	//CPOL = 0 & CPHA = 1
#define IDLE_MODE_2 2	//CPOL = 1 & CPHA = 0
#define IDLE_MODE_3 3	//CPOL = 1 & CPHA = 1
#define _IS_SPI_IDLE_MODE(mode) ((mode == IDLE_MODE_0) || (mode == IDLE_MODE_1) ||\
								(mode == IDLE_MODE_2) || (mode == IDLE_MODE_3))

typedef struct
{
	uint8_t mosi;
	uint8_t miso;
	uint8_t sck;
	uint8_t cs1;
	uint8_t	mode 		: 1;
	uint8_t	idle_mode 	: 2;
	uint8_t soft_control : 1;
}cw32_hal_spi_struct;


#endif



